Added $wgShowHostnames to shows/hide host names in API results and HTML comments
authorYuri Astrakhan <yurik@users.mediawiki.org>
Tue, 10 Jul 2007 13:46:22 +0000 (13:46 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Tue, 10 Jul 2007 13:46:22 +0000 (13:46 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/Wiki.php
includes/api/ApiQuerySiteinfo.php

index b4d3af0..d962d81 100644 (file)
@@ -25,6 +25,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * $wgAddGroups, $wgRemoveGroups - Finer control over who can assign which
   usergroups
 * $wgEnotifImpersonal, $wgEnotifUseJobQ - Bulk mail options for large sites
+* $wgShowHostnames - Shows host names in API results and HTML comments
 
 == New features since 1.10 ==
 
index 2a70250..74ffbe4 100644 (file)
@@ -921,7 +921,11 @@ $wgColorErrors          = true;
 $wgShowExceptionDetails = false;
 
 /**
- * disable experimental dmoz-like category browsing. Output things like:
+ * If set to true, exposes host names through API and HTML comments.
+ */
+$wgShowHostnames = false;
+/** * disable experimental dmoz-like category browsing. Output things like:
  * Encyclopedia > Music > Style of Music > Jazz
  */
 $wgUseCategoryBrowser   = false;
index aaf150c..a1db8f8 100644 (file)
@@ -701,14 +701,16 @@ function wfHostname() {
         * @return string
         */
        function wfReportTime() {
-               global $wgRequestTime;
+               global $wgRequestTime, $wgShowHostnames;
 
                $now = wfTime();
                $elapsed = $now - $wgRequestTime;
 
-               $com = sprintf( "<!-- Served by %s in %01.3f secs. -->",
-                 wfHostname(), $elapsed );
-               return $com;
+        if ($wgShowHostnames) {
+            return sprintf( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed );
+        } else {
+            return sprintf( "<!-- Served in %01.3f secs. -->", $elapsed );
+        }
        }
 
 /**
index 924a977..9593033 100644 (file)
@@ -57,14 +57,19 @@ class MediaWiki {
        }
 
        function checkMaxLag( $maxLag ) {
-               global $wgLoadBalancer;
+               global $wgLoadBalancer, $wgShowHostnames;
+               
                list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
                if ( $lag > $maxLag ) {
                        header( 'HTTP/1.1 503 Service Unavailable' );
                        header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
                        header( 'X-Database-Lag: ' . intval( $lag ) );
                        header( 'Content-Type: text/plain' );
-                       echo "Waiting for $host: $lag seconds lagged\n";
+                       if ($wgShowHostnames) {
+                               echo "Waiting for $host: $lag seconds lagged\n";
+                       } else {
+                               echo "Waiting for a database server: $lag seconds lagged\n";
+                       }
                        return false;
                } else {
                        return true;
index 9f10a61..c3bfbc0 100644 (file)
@@ -132,11 +132,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
        
        protected function appendDbReplLagInfo($property, $includeAll) {
-               global $wgLoadBalancer;
+               global $wgLoadBalancer, $wgShowHostnames;
 
                $data = array();
                
                if ($includeAll) {
+                       if (!$wgShowHostnames)
+                               $this->dieUsage('Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied');
+                       
                        global $wgDBservers;
                        $lags = $wgLoadBalancer->getLagTimes();
                        foreach( $lags as $i => $lag ) {
@@ -147,7 +150,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                } else {
                        list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
                        $data[] = array (
-                               'host' => $host,
+                               'host' => $wgShowHostnames ? $host : '',
                                'lag' => $lag);
                }